﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class inquiry : System.Web.UI.Page
{

    db database;
    protected void Page_Load(object sender, EventArgs e)
    {
        database = new db();
        string TourName = database.getTourName(Request["id"]);
        this.TourLabel.Text = "Book the " + TourName + " Tour";
    }
    protected void Submit_Click(object sender, EventArgs e)
    {
        String firstName = this.FirstName.Text;
        String lastName = this.LastName.Text;
        String email = this.Email.Text;
        String comments = this.Comments.Text;
        String destinationID = Request["id"];
        if (firstName == "" || lastName == "" || email == "")
        {
            this.ErrorLabel.Text = "You cannot leave the First Name, Last Name, or Email fields blank";
            this.ErrorLabel.Visible = true;
        }
        else
        {
            int result = database.addInquiryEntry(destinationID, firstName, lastName, email, comments);
            if (result == 1)
                this.Response.Redirect("~/Sucess.aspx");
            else
            {
                this.ErrorLabel.Text = "Your request could not be completed please try again later";
                this.ErrorLabel.Visible = true;
            }
        }
    }
    protected void Cancel_Click(object sender, EventArgs e)
    {
        this.Response.Redirect("~/Default.aspx");
    }
}